<?php

    /**
 * ProcessSimpleType method
 * @param string $who name of the person we'll say hello to
 * @return string $helloText the hello  string
 */
    require_once ("lib/nusoap.php");
    require_once ("User.php");
    
    $ns = "http://localhost:8080/Webservice";
    $server = new soap_server();
    
    //Configure WSDL
    $server->configureWSDL("UserDetail");
    $server->wsdl->schemaTargetNamespace = $ns;
    
    //Creating Complex type for out put (Only for single record)
    $server->wsdl->addComplexType(
            'UserDetailRow',
            'ComplexType',
            'struct',
            'all',
            '',
            array(
                'UserId'=>array('name'=>'Id','type'=>'xsd:int'),
                'UserName'=>array('name'=>'Name','type'=>'xsd:string'),
                'Email'=>array('name'=>'Email','type'=>'xsd:string')
            )
            );
    //Complex type for multiple record output
    $server->wsdl->addComplexType(
            'UserDetailRows',
            'ComplexType',
            'array',
            '',
            'SOAP-ENC:Array',
            array(),
            array(
                array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:UserDetailRow[]')
            ),
            'tns:UserDetailRow');
    //Registering getUserDetail function for WDSL generation
   $server->register(
            'getUserDetail1', //function name
            array(), //input
            array('return'=>'tns:UserDetailRows'), //output
            $ns,      //namesapace
            false,
            'rpc',   //style
            'encoded', //use
            'Fetching User Detail'  //documentation
            );
   $server->register(
            'insertUser1',
            array('name'=>'xsd:string', 'email'=>'xsd:string'),
            array('return'=>'xsd:string'),
            $ns,
            false,
            'rpc',
            'encoded',
            'Insert User'
            );
    //Main function
    function getUserDetail1()
    {
        $UserDetail = new User;      //Object from User.php
        return $UserDetail->getUserDetail();
    }
    function insertUser1($name, $email)
    {
        $ins = new User;
        return $ins->insertUser($name, $email);
    }
    //out put return
    $HTTP_RAW_POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA'])?$GLOBALS['HTTP_RAW_POST_DATA']:'';
    $server->service($HTTP_RAW_POST_DATA);
    exit();
?>